using System;
using System.ComponentModel;
using System.Threading;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.DataContracts;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.EventArgs;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.Interfaces;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.Respondents;

namespace FU.Capstones.IMS.Web.Common.InventoryServiceProxy.OperationContracts
{
    public partial class InventoryServiceClient
    {

        #region GetAuthorizationCollection

        public event EventHandler<CollectionFeedbackCompletedEventArgs<Authorization>> GetAuthorizationCollectionCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginGetAuthorizationCollection(bool isShowAll, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginGetAuthorizationCollection(isShowAll, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        CollectionFeedback<Authorization> IInventoryService.EndGetAuthorizationCollection(IAsyncResult result)
        {
            return Channel.EndGetAuthorizationCollection(result);
        }

        private IAsyncResult OnBeginGetAuthorizationCollection(object[] inValues, AsyncCallback callback, object asyncState)
        {
            bool isShowAll = (bool)inValues[0];

            return ((IInventoryService)(this)).BeginGetAuthorizationCollection(isShowAll, callback, asyncState);
        }

        private object[] OnEndGetAuthorizationCollection(IAsyncResult result)
        {
            CollectionFeedback<Authorization> retVal = ((IInventoryService)(this)).EndGetAuthorizationCollection(result);
            return new object[] { retVal };
        }

        private void OnGetAuthorizationCollectionCompleted(object state)
        {
            if ((GetAuthorizationCollectionCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                GetAuthorizationCollectionCompleted(this, new CollectionFeedbackCompletedEventArgs<Authorization>(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void GetAuthorizationCollectionAsync(bool isShowAll)
        {
            GetAuthorizationCollectionAsync(isShowAll, null);
        }

        public void GetAuthorizationCollectionAsync(bool isShowAll, object userState)
        {
            if ((onBeginGetAuthorizationCollectionDelegate == null))
            {
                onBeginGetAuthorizationCollectionDelegate = new BeginOperationDelegate(OnBeginGetAuthorizationCollection);
            }
            if ((onEndGetAuthorizationCollectionDelegate == null))
            {
                onEndGetAuthorizationCollectionDelegate = new EndOperationDelegate(OnEndGetAuthorizationCollection);
            }
            if ((onGetAuthorizationCollectionCompletedDelegate == null))
            {
                onGetAuthorizationCollectionCompletedDelegate = new SendOrPostCallback(OnGetAuthorizationCollectionCompleted);
            }
            InvokeAsync(onBeginGetAuthorizationCollectionDelegate, new object[] {
                    isShowAll}, onEndGetAuthorizationCollectionDelegate, onGetAuthorizationCollectionCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginGetAuthorizationCollectionDelegate;

        private EndOperationDelegate onEndGetAuthorizationCollectionDelegate;

        private SendOrPostCallback onGetAuthorizationCollectionCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginGetAuthorizationCollection(bool isShowAll, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = isShowAll;

                IAsyncResult _result = BeginInvoke("GetAuthorizationCollection", _args, callback, asyncState);
                return _result;
            }

            public CollectionFeedback<Authorization> EndGetAuthorizationCollection(IAsyncResult result)
            {
                object[] _args = new object[0];
                CollectionFeedback<Authorization> _result = ((CollectionFeedback<Authorization>)(EndInvoke("GetAuthorizationCollection", _args, result)));
                return _result;
            }
        }

        #endregion
        
        #region GetSingleAuthorization

        public event EventHandler<SingleFeedbackCompletedEventArgs<Authorization>> GetSingleAuthorizationCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginGetSingleAuthorization(int objectID, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginGetSingleAuthorization(objectID, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        SingleFeedback<Authorization> IInventoryService.EndGetSingleAuthorization(IAsyncResult result)
        {
            return Channel.EndGetSingleAuthorization(result);
        }

        private IAsyncResult OnBeginGetSingleAuthorization(object[] inValues, AsyncCallback callback, object asyncState)
        {
            int objectID = (int)inValues[0];

            return ((IInventoryService)(this)).BeginGetSingleAuthorization(objectID, callback, asyncState);
        }

        private object[] OnEndGetSingleAuthorization(IAsyncResult result)
        {
            SingleFeedback<Authorization> retVal = ((IInventoryService)(this)).EndGetSingleAuthorization(result);
            return new object[] { retVal };
        }

        private void OnGetSingleAuthorizationCompleted(object state)
        {
            if ((GetSingleAuthorizationCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                GetSingleAuthorizationCompleted(this, new SingleFeedbackCompletedEventArgs<Authorization>(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void GetSingleAuthorizationAsync(int objectID)
        {
            GetSingleAuthorizationAsync(objectID, null);
        }

        public void GetSingleAuthorizationAsync(int objectID, object userState)
        {
            if ((onBeginGetSingleAuthorizationDelegate == null))
            {
                onBeginGetSingleAuthorizationDelegate = new BeginOperationDelegate(OnBeginGetSingleAuthorization);
            }
            if ((onEndGetSingleAuthorizationDelegate == null))
            {
                onEndGetSingleAuthorizationDelegate = new EndOperationDelegate(OnEndGetSingleAuthorization);
            }
            if ((onGetSingleAuthorizationCompletedDelegate == null))
            {
                onGetSingleAuthorizationCompletedDelegate = new SendOrPostCallback(OnGetSingleAuthorizationCompleted);
            }
            InvokeAsync(onBeginGetSingleAuthorizationDelegate, new object[] {
                                                                                         objectID}, onEndGetSingleAuthorizationDelegate, onGetSingleAuthorizationCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginGetSingleAuthorizationDelegate;

        private EndOperationDelegate onEndGetSingleAuthorizationDelegate;

        private SendOrPostCallback onGetSingleAuthorizationCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginGetSingleAuthorization(int objectID, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = objectID;

                IAsyncResult _result = BeginInvoke("GetSingleAuthorization", _args, callback, asyncState);
                return _result;
            }

            public SingleFeedback<Authorization> EndGetSingleAuthorization(IAsyncResult result)
            {
                object[] _args = new object[0];
                SingleFeedback<Authorization> _result = ((SingleFeedback<Authorization>)(EndInvoke("GetSingleAuthorization", _args, result)));
                return _result;
            }
        }

        #endregion

        #region InsertAuthorization

        public event EventHandler<SingleFeedbackCompletedEventArgs<int>> InsertAuthorizationCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginInsertAuthorization(Authorization data, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginInsertAuthorization(data, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        SingleFeedback<int> IInventoryService.EndInsertAuthorization(IAsyncResult result)
        {
            return Channel.EndInsertAuthorization(result);
        }

        private IAsyncResult OnBeginInsertAuthorization(object[] inValues, AsyncCallback callback, object asyncState)
        {
            Authorization data = (Authorization)inValues[0];

            return ((IInventoryService)(this)).BeginInsertAuthorization(data, callback, asyncState);
        }

        private object[] OnEndInsertAuthorization(IAsyncResult result)
        {
            SingleFeedback<int> retVal = ((IInventoryService)(this)).EndInsertAuthorization(result);
            return new object[] { retVal };
        }

        private void OnInsertAuthorizationCompleted(object state)
        {
            if ((InsertAuthorizationCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                InsertAuthorizationCompleted(this, new SingleFeedbackCompletedEventArgs<int>(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void InsertAuthorizationAsync(Authorization data)
        {
            InsertAuthorizationAsync(data, null);
        }

        public void InsertAuthorizationAsync(Authorization data, object userState)
        {
            if ((onBeginInsertAuthorizationDelegate == null))
            {
                onBeginInsertAuthorizationDelegate = new BeginOperationDelegate(OnBeginInsertAuthorization);
            }
            if ((onEndInsertAuthorizationDelegate == null))
            {
                onEndInsertAuthorizationDelegate = new EndOperationDelegate(OnEndInsertAuthorization);
            }
            if ((onInsertAuthorizationCompletedDelegate == null))
            {
                onInsertAuthorizationCompletedDelegate = new SendOrPostCallback(OnInsertAuthorizationCompleted);
            }
            InvokeAsync(onBeginInsertAuthorizationDelegate, new object[] {
                                                                                      data}, onEndInsertAuthorizationDelegate, onInsertAuthorizationCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginInsertAuthorizationDelegate;

        private EndOperationDelegate onEndInsertAuthorizationDelegate;

        private SendOrPostCallback onInsertAuthorizationCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginInsertAuthorization(Authorization data, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = data;

                IAsyncResult _result = BeginInvoke("InsertAuthorization", _args, callback, asyncState);
                return _result;
            }

            public SingleFeedback<int> EndInsertAuthorization(IAsyncResult result)
            {
                object[] _args = new object[0];
                SingleFeedback<int> _result = ((SingleFeedback<int>)(EndInvoke("InsertAuthorization", _args, result)));
                return _result;
            }
        }

        #endregion

        #region UpdateAuthorization

        public event EventHandler<FeedbackCompletedEventArgs> UpdateAuthorizationCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginUpdateAuthorization(Authorization data, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginUpdateAuthorization(data, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        Feedback IInventoryService.EndUpdateAuthorization(IAsyncResult result)
        {
            return Channel.EndUpdateAuthorization(result);
        }

        private IAsyncResult OnBeginUpdateAuthorization(object[] inValues, AsyncCallback callback, object asyncState)
        {
            Authorization data = (Authorization)inValues[0];

            return ((IInventoryService)(this)).BeginUpdateAuthorization(data, callback, asyncState);
        }

        private object[] OnEndUpdateAuthorization(IAsyncResult result)
        {
            Feedback retVal = ((IInventoryService)(this)).EndUpdateAuthorization(result);
            return new object[] { retVal };
        }

        private void OnUpdateAuthorizationCompleted(object state)
        {
            if ((UpdateAuthorizationCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                UpdateAuthorizationCompleted(this, new FeedbackCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void UpdateAuthorizationAsync(Authorization data)
        {
            UpdateAuthorizationAsync(data, null);
        }

        public void UpdateAuthorizationAsync(Authorization data, object userState)
        {
            if ((onBeginUpdateAuthorizationDelegate == null))
            {
                onBeginUpdateAuthorizationDelegate = new BeginOperationDelegate(OnBeginUpdateAuthorization);
            }
            if ((onEndUpdateAuthorizationDelegate == null))
            {
                onEndUpdateAuthorizationDelegate = new EndOperationDelegate(OnEndUpdateAuthorization);
            }
            if ((onUpdateAuthorizationCompletedDelegate == null))
            {
                onUpdateAuthorizationCompletedDelegate = new SendOrPostCallback(OnUpdateAuthorizationCompleted);
            }
            InvokeAsync(onBeginUpdateAuthorizationDelegate, new object[] {
                                                                                      data}, onEndUpdateAuthorizationDelegate, onUpdateAuthorizationCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginUpdateAuthorizationDelegate;

        private EndOperationDelegate onEndUpdateAuthorizationDelegate;

        private SendOrPostCallback onUpdateAuthorizationCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginUpdateAuthorization(Authorization data, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = data;

                IAsyncResult _result = BeginInvoke("UpdateAuthorization", _args, callback, asyncState);
                return _result;
            }

            public Feedback EndUpdateAuthorization(IAsyncResult result)
            {
                object[] _args = new object[0];
                Feedback _result = ((Feedback)(EndInvoke("UpdateAuthorization", _args, result)));
                return _result;
            }
        }

        #endregion

        #region DeleteAuthorization

        public event EventHandler<FeedbackCompletedEventArgs> DeleteAuthorizationCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginDeleteAuthorization(int data, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginDeleteAuthorization(data, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        Feedback IInventoryService.EndDeleteAuthorization(IAsyncResult result)
        {
            return Channel.EndDeleteAuthorization(result);
        }

        private IAsyncResult OnBeginDeleteAuthorization(object[] inValues, AsyncCallback callback, object asyncState)
        {
            int data = (int)inValues[0];

            return ((IInventoryService)(this)).BeginDeleteAuthorization(data, callback, asyncState);
        }

        private object[] OnEndDeleteAuthorization(IAsyncResult result)
        {
            Feedback retVal = ((IInventoryService)(this)).EndDeleteAuthorization(result);
            return new object[] { retVal };
        }

        private void OnDeleteAuthorizationCompleted(object state)
        {
            if ((DeleteAuthorizationCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                DeleteAuthorizationCompleted(this, new FeedbackCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void DeleteAuthorizationAsync(int objID)
        {
            DeleteAuthorizationAsync(objID, null);
        }

        public void DeleteAuthorizationAsync(int data, object userState)
        {
            if ((onBeginDeleteAuthorizationDelegate == null))
            {
                onBeginDeleteAuthorizationDelegate = new BeginOperationDelegate(OnBeginDeleteAuthorization);
            }
            if ((onEndDeleteAuthorizationDelegate == null))
            {
                onEndDeleteAuthorizationDelegate = new EndOperationDelegate(OnEndDeleteAuthorization);
            }
            if ((onDeleteAuthorizationCompletedDelegate == null))
            {
                onDeleteAuthorizationCompletedDelegate = new SendOrPostCallback(OnDeleteAuthorizationCompleted);
            }
            InvokeAsync(onBeginDeleteAuthorizationDelegate, new object[] {
                                                                                      data}, onEndDeleteAuthorizationDelegate, onDeleteAuthorizationCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginDeleteAuthorizationDelegate;

        private EndOperationDelegate onEndDeleteAuthorizationDelegate;

        private SendOrPostCallback onDeleteAuthorizationCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginDeleteAuthorization(int data, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = data;

                IAsyncResult _result = BeginInvoke("DeleteAuthorization", _args, callback, asyncState);
                return _result;
            }

            public Feedback EndDeleteAuthorization(IAsyncResult result)
            {
                object[] _args = new object[0];
                Feedback _result = ((Feedback)(EndInvoke("DeleteAuthorization", _args, result)));
                return _result;
            }
        }

        #endregion

        #region SearchAuthorization

        public event EventHandler<CollectionFeedbackCompletedEventArgs<Authorization>> SearchAuthorizationCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginSearchAuthorization(Authorization criteria, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginSearchAuthorization(criteria, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        CollectionFeedback<Authorization> IInventoryService.EndSearchAuthorization(IAsyncResult result)
        {
            return Channel.EndSearchAuthorization(result);
        }

        private IAsyncResult OnBeginSearchAuthorization(object[] inValues, AsyncCallback callback, object asyncState)
        {
            Authorization criteria = (Authorization)inValues[0];

            return ((IInventoryService)(this)).BeginSearchAuthorization(criteria, callback, asyncState);
        }

        private object[] OnEndSearchAuthorization(IAsyncResult result)
        {
            CollectionFeedback<Authorization> retVal = ((IInventoryService)(this)).EndSearchAuthorization(result);
            return new object[] { retVal };
        }

        private void OnSearchAuthorizationCompleted(object state)
        {
            if ((SearchAuthorizationCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                SearchAuthorizationCompleted(this, new CollectionFeedbackCompletedEventArgs<Authorization>(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void SearchAuthorizationAsync(Authorization criteria)
        {
            SearchAuthorizationAsync(criteria, null);
        }

        public void SearchAuthorizationAsync(Authorization criteria, object userState)
        {
            if ((onBeginSearchAuthorizationDelegate == null))
            {
                onBeginSearchAuthorizationDelegate = new BeginOperationDelegate(OnBeginSearchAuthorization);
            }
            if ((onEndSearchAuthorizationDelegate == null))
            {
                onEndSearchAuthorizationDelegate = new EndOperationDelegate(OnEndSearchAuthorization);
            }
            if ((onSearchAuthorizationCompletedDelegate == null))
            {
                onSearchAuthorizationCompletedDelegate = new SendOrPostCallback(OnSearchAuthorizationCompleted);
            }
            InvokeAsync(onBeginSearchAuthorizationDelegate, new object[] {
                                                                                      criteria}, onEndSearchAuthorizationDelegate, onSearchAuthorizationCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginSearchAuthorizationDelegate;

        private EndOperationDelegate onEndSearchAuthorizationDelegate;

        private SendOrPostCallback onSearchAuthorizationCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginSearchAuthorization(Authorization criteria, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = criteria;

                IAsyncResult _result = BeginInvoke("SearchAuthorization", _args, callback, asyncState);
                return _result;
            }

            public CollectionFeedback<Authorization> EndSearchAuthorization(IAsyncResult result)
            {
                object[] _args = new object[0];
                CollectionFeedback<Authorization> _result = ((CollectionFeedback<Authorization>)(EndInvoke("SearchAuthorization", _args, result)));
                return _result;
            }
        }

        #endregion

    }
}